package com.dosen.api.thought.runner;


import com.dosen.api.base.common.utils.common.SpringBeanUtil;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import java.util.Arrays;


/**
 * @version V1.0
 * @author: guangcheng
 * @date: 2023/1/23 20:39
 * @description: "com.dosen.api.third.party.*", "com.dosen.api.common.*"
 */
@Slf4j
@SpringBootApplication//(exclude = {DataSourceAutoConfiguration.class})
@EnableAspectJAutoProxy(proxyTargetClass = true)
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"com.dosen.api.*"})
@EnableScheduling
@EnableAsync
@ComponentScan(basePackages = {"com.dosen.api.thought.*"})
@EnableCaching
@EnableTransactionManagement
@MapperScan({"com.dosen.api.thought.core.service.dao"})
public class DosenThoughtAppRunner implements CommandLineRunner {

    public static void main(String[] args) {
        ConfigurableApplicationContext run = SpringApplication.run(DosenThoughtAppRunner.class, args);
        Arrays.stream(run.getBeanDefinitionNames()).forEach(System.out::println);
        System.out.println("run.getBeanDefinitionCount() = " + run.getBeanDefinitionCount());
        SpringBeanUtil.setApplicationContext(run);
    }

    @Override
    public void run(String... args) throws Exception {
        log.info(">>>>>>>>>>>>>>>>>>> DosenThoughtAppRunner 启动完成 <<<<<<<<<<<<<<<<<<<<<<<");
    }
}

